package org.itsolutions.javaBackup.gui.web.common.composites;

import org.itsolutions.javaBackup.gui.web.common.components.IView;
import org.itsolutions.javaBackup.gui.web.common.components.JBGridLayout;

import com.google.inject.Inject;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;

/**
 * 
 * @author Tomas Fecko
 *|------------------|
 *|		  LOGO		 |
 *|------------------|
 *|	   TOP PANEL     |
 *|------------------|
 *| MENU |   MAIN	 |
 *|		 |	 PANEL	 |
 *|------------------|
 */
public final class LayoutComposite extends CustomComponent implements IView<LayoutComposite> {

	private static final long 	serialVersionUID = -5192938751101322988L;
	@Inject JBGridLayout		mGrid;
	
	@Override
	public LayoutComposite init() {
		setCompositionRoot(mGrid);
		mGrid.setGrid(2, 3);
		mGrid.setSizeFull();
		mGrid.setSpacing(true);
		mGrid.setMargin(true);
		mGrid.setColumnExpandRatio(1, 1);
		return this;
	}

	@Override
	public ComponentContainer getMainContainer() {
		return this;
	}

	/**
	 * 
	 * @param pParent parent component
	 * @return this
	 */
	public LayoutComposite setParentComponent(Component pParent) {
		setParent(pParent);
		return this;
	}
	
	/**
	 * 
	 * @param pLogo logo
	 */
	public void setLogo(Component pLogo) {
		pLogo.setHeight("70px");
		mGrid.addComponent(pLogo, 0, 0, 1, 0);
	}
	
	/**
	 * 
	 * @param pPanel top panel
	 */
	public void setTop(Component pPanel) {
		pPanel.setWidth("100%");
		pPanel.setHeight("39px");
		mGrid.addComponent(pPanel, 0, 1, 1, 1);
	}
	
	/**
	 * 
	 * @param pMenu menu
	 */
	public void setMenu(Component pMenu) {
		pMenu.setWidth("200px");
		pMenu.setHeight("400px");
		mGrid.addComponent(pMenu, 0, 2, 0, 2);
	}
	
	/**
	 * 
	 * @param pPanel main panel
	 */
	public void setMain(Component pPanel) {
		pPanel.setWidth("100%");
		pPanel.setHeight("600px");
		mGrid.addComponent(pPanel, 1, 2, 1, 2);		
		mGrid.setComponentAlignment(pPanel, Alignment.TOP_LEFT);
	}
}





